"""
领取客户
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
import unittest
#定位器
name_locator = (By.NAME, "name")
password_locator = (By.NAME, "password")
login_locator = (By.CSS_SELECTOR, "body > div.container > div > div.span4 > div > form > fieldset > input.btn.btn-primary")
kh_link_locator =(By.LINK_TEXT,"客户")
kh_khc_locator = (By.CSS_SELECTOR,"body > div.container > div.page-header > ul > li:nth-child(2) > a")
kh_khc_lq_locator = (By.CSS_SELECTOR,"#form1 > table > tbody > tr:nth-child(1) > td:nth-child(9) > a:nth-child(4)")
#数据
name = "admin"
password = "123456"
#操作
#打开浏览器
driver = webdriver.Chrome()
#最大化窗口
driver.maximize_window()
#进入悟空CRM登录界面
driver.get("http://192.168.1.25/crm/")
#输入用户名
driver.find_element(*name_locator).send_keys(name)
#输入密码
driver.find_element(*password_locator).send_keys(password)
#点击确定按钮
driver.find_element(*login_locator).click()
#点击线索按钮
driver.find_element(*kh_link_locator).click()
#点击客户池
driver.find_element(*kh_khc_locator).click()
#点击领取按钮
driver.find_element(*kh_khc_lq_locator).click()
sleep(1)

if __name__ == '__main__':
    unittest.main()